<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@	page import="kau.dao.*"%>
<%@	page import="kau.vo.*"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="java.util.HashMap"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<title>수강신청 내역조회</title>

<script type="text/javascript">
	function showList() {

		var idx = f.sel.options.selectedIndex;
		var courseId = f.sel.options[idx].value;

		//var fname = document.search;
		//var courseId = fname.courseId.options[search.courseId.selectedIndex].value;
		//var courseId = $("#courseId option:selected").val();
		//alert(courseId);

		location.replace("confirm.registeration?courseId=" + courseId);

	}
	function update(custId, courseId) {
		alert('업데이트 되었습니다');

		var theForm = document.f;
		theForm.method = "post";
		theForm.action = "update.registeration?courseId=" + courseId
				+ "&custId=" + custId + "&isConfirm=1";

		theForm.submit();
	}
</script>

<style type="text/css">
<!--
@import url("css/style.css");
-->
</style>


<style type="text/css">
#info {
	font-family: 맑은 고딕, dotum, sans-serif, bold;
	font-size: 13px
}
</style>

</head>

<body>
	<%
		ArrayList<Course> allCourseList = CourseDAOImpl.getInstance()
				.getAllCourses();
	%>


	<div id="info">
		<br>
		<table align="left" style="margin-left: 20px">
			<tr>

				<td width="60" height="50"><img
					src="/nems/admin/images/enroll.png" width="40"/></td>

				<td>
					<h4
						style="font-weight: bold; color: #005700; text-align: left; font-size: 20px;">수강 신청
						승인</h4>
				</td>
			</tr>
		</table>
		<br> <br>



		<form action="confirm.registeration" name="f" method="post">
			<p align="right" style="margin-right: 25px"><strong>카테고리 선택 : </strong> <select class="form-control input-small"
				name="sel" onchange="showList()">
				<option value='0'>과목선택</option>
				<%
					for (int i = 0; i < allCourseList.size(); i++) {
				%>
				<option value="<%=allCourseList.get(i).getCourseId()%>">
					<%=allCourseList.get(i).getCourseName() + '-'
						+ allCourseList.get(i).getLecturer()%></option>
				<%
					}
				%>
			</select>
<center>
			<table id="newspaper-a" style="width: 700px">
				<thead>
					<tr align="center">
						<th width="10%">No.</th>
						<th width="20%">아이디</th>
						<th width="15%">이름</th>
						<th width="30%">과목명</th>
						<th width="25%">수강 승인 여부</th>
					</tr>
				</thead>



				<c:set var="customerList" value="${requestScope.customerList}"></c:set>
				<c:set var="courseList" value="${requestScope.courseList}"></c:set>


				<tbody>

					<c:forEach var="regist" items="${requestScope.registerList}"
						step="1" varStatus="status">
						<tr align="center">
							<td>${status.index+1}</td>
							<td>${customerList[status.index].custId}</td>
							<td>${customerList[status.index].custName}</td>
							<td>${courseList[status.index].courseName}</td>




							<c:set var="isConfirm" value='${regist.isConfirm}'></c:set>
							<td><c:if test="${isConfirm=='0'}">

									<button class="positive"
										onclick="update('${customerList[status.index].custId}','${courseList[status.index].courseId}')"
										type="button">
										<img src="admin/images/add.png"
											style="width: 20px; height: 10px" />승인하기
									</button>


								</c:if> <c:if test="${isConfirm=='1'}">
									<button disabled>
										<img src="admin/images/tick.png"
											style="width: 20px; height: 10px" />승인완료
									</button>


								</c:if></td>

						</tr>
					</c:forEach>
				</tbody>
			</table>
</center>
		</form>
	</div>
	<br>
	<center>
		<a href="javascript:history.go(-1)" class="css_btn_class">이전화면으로</a>
	</center>


</body>
</html>